package com.example.prjbackend.mapper;

import com.example.prjbackend.domain.Bumen;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BumenMapper {
    @Insert("insert into bumen(bname,bdescp) values(#{bname},#{bdescp})")
    int insert(Bumen bumen);

    @Select("<script>select bid,bname,bdescp from bumen" +
            "<where>" +
            " <if test='bname!=null'>and bname like concat('%',#{bname},'%')</if>" +
            " <if test='bdescp!=null'>and bdescp like concat('%',#{bdecp},'%')</if>" +
            "</where>" +
            "</script>")
    List<Bumen> list(Bumen bumen);

    @Update("<script>" +
            "update bumen " +
            "<set>" +
            "  <if test='bname!=null'>bname=#{bname},</if>" +
            "  <if test='bdescp!=null'>bdescp=#{bdescp},</if>" +
            "</set>" +
            " where bid=#{bid}" +
            "</script>")
    int edit(Bumen bumen);


    @Delete("<script>" +
            "delete from bumen where bid in " +
            "<foreach collection='array' item='bid' open='(' close=')' separator=','>" +
              "#{bid}" +
            "</foreach>" +
            "</script>")
    int delete(Long[] ids);
}
